<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>使用h2xs打包模块</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="Tar.html">Tar</a>&nbsp;&nbsp;>>Next: <a href="RSS.html">给网页增加RSS</a></p>
<h1>使用h2xs打包模块</h1>
<div class='content'>
<p>Category: <a href='Basic.html'>Basic</a> &nbsp; Keywords: <b>h2xs tarball</b></p><h2>描述</h2>
闲着无聊就看看了perlnewmod, 发现一种与“<a href='Module_Build.html'>Module::Build</a>”不一样的打包方式。<br>
试了下，个人发现比Module::Build好一点。Module::Build打包出来的模块安装时必须要先安装Module::Build，而且h2xs还生成了简单的t(test)文件。而且我发现目前<a href='http://search.cpan.org'>CPAN</a>上的模块大多是用h2xs制作的。

<h2>h2xs 参数简介</h2>
<ul>OPTION/选项：（不完整版，详细的请参考perldoc h2xs或h2xs -h）
<li>-A, --omit-autoload 忽略autoload里的文件（-c里默认包含）
<li>-B, --beta-version 使用alpha/beta型的版本号（如0.00_01），如果存在-v则忽略次参数
<li>-C, --omit-changes 不创建CHANGES文件，而在POD模版中增加HISTORY段
<li>-O, --overwrite-ok 允许覆盖已存在的扩展目录
<li>-X, --omit-XS 忽略XS部分（-c和-f里默认包含）
<li>-b, --compat-version 指定一个perl版本号用于向后兼容
<li>-d, --debugging 显示调试信息
<li>-n, --name 指定扩展的名字
</ul>

<h2>过程</h2>
假设打包的是我的模块，<a href='Han2PinYin.html'>Lingua::Han2PinYin</a><br>
首先进入控制台(console)
<pre>
>h2xs -AX -n Lingua::Han2PinYin
</pre>
此命令的作用仅仅限于生成tar所需要的目录和一些文件。<br>
<pre>
lib/Lingua/Han2PinYin.pm
t/Lingua-Han2PinYin.t
Makefile.PL
README
Changes
MANIFEST
</pre>
<b>上面所生成的所有文件都是需要修改的。</b><br>
<ol>
<li>将自己写的Han2PinYin.pm覆盖生成的Han2PinYin<br>
<li>Makefile.PL里首先需要去掉"use 5.008004;"或者改为你所需要的版本号。其次要修改AUTHOR
<li>t下面的测试文件，如果需要增加新的测试则自行增加，不需要的话略过。
<li>README Changes 文件请自行修改
<li>MANIFEST则不需要修改
</ol>
弄完后：
<pre>
>cd Lingua-Han2PinYin
>perl Makefile.PL
>(n)make test
>(n)make dist
</pre>
在Linux/Unix系统下用make，Win32系统下用nmake<br>
至此差不多结束。会生成Lingua-Han2PinYin-0.04.tar.gz

<h2>Refer</h2>
<ul>
<li><a href='http://www.cpan.org/modules/04pause.html'>CPAN/modules/04pause.html</a>
<li>perldoc <a href='http://search.cpan.org/perldoc?perlnewmod'>perlnewmod</a>
</ul>
</div>
<p><&lt;Previous: <a href="Tar.html">Tar</a>&nbsp;&nbsp;>>Next: <a href="RSS.html">给网页增加RSS</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=%E4%BD%BF%E7%94%A8h2xs%E6%89%93%E5%8C%85%E6%A8%A1%E5%9D%97&url=http://www.fayland.org/journal/h2xs.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='PerlTidy.html'>PerlTidy</a> < <span class='digit'>2004-10-30 19:23:26</span> ></li><li><a href='Highlight.html'>如何将Perl代码着色</a> < <span class='digit'>2004-11-20 22:13:22</span> ></li><li><a href='ask_tim.html'>Perl 6 什么时候才能完成？</a> < <span class='digit'>2004-12-30 18:42:06</span> ></li><li><a href='Perl6_ES14.html'>has $.Examples14 handles 'Perl6';</a> < <span class='digit'>2005-06-02 01:38:59</span> ></li><li><a href='050312.html'>给 eclipse 安装 EPIC plug-in</a> < <span class='digit'>2005-03-12 20:56:04</span> ></li><li><a href='050401.html'>Win32 下 Apache 和 #!/usr/bin/perl</a> < <span class='digit'>2005-04-01 10:10:59</span> ></li><li><a href='050519.html'>Synopsis localization</a> < <span class='digit'>2005-05-19 11:21:25</span> ></li><li><a href='Perl6_ES0.html'>@Examples[0] is Perl6</a> < <span class='digit'>2005-05-19 20:26:08</span> ></li><li><a href='Perl6_ES1.html'>given @Examples[1] when Perl6</a> < <span class='digit'>2005-05-19 22:05:56</span> ></li><li><a href='Perl6_ES2.html'>@Perl6 <== @Examples xx 2</a> < <span class='digit'>2005-05-20 18:53:54</span> ></li><li><a href='Perl6_ES3.html'>my Perl6 @Examples[3]</a> < <span class='digit'>2005-05-21 13:53:16</span> ></li><li><a href='Perl6_ES4.html'>say q:2 '@*Examples.[4] &Perl6()';</a> < <span class='digit'>2005-05-22 12:24:12</span> ></li><li><a href='Perl6_ES5.html'>sub Perl6 (*@Examples[5] is copy)</a> < <span class='digit'>2005-05-22 15:37:26</span> ></li><li><a href='Perl6_ES6.html'>multi sub Examples (6, Perl6) {...}</a> < <span class='digit'>2005-05-23 22:43:33</span> ></li><li><a href='Perl6_ES7.html'>sub infix:<(7)> ($Perl6, @Examples)</a> < <span class='digit'>2005-05-24 02:16:42</span> ></li><li><a href='Perl6_ES8.html'>let @Examples[8] = 'Perl6';</a> < <span class='digit'>2005-05-24 13:05:58</span> ></li><li><a href='050524.html'>The Shanghai PerlMonger meeting</a> < <span class='digit'>2005-05-24 20:41:25</span> ></li><li><a href='Perl6_ES9.html'>Perl6 | Examples & 9 ^ junction</a> < <span class='digit'>2005-05-26 12:35:29</span> ></li><li><a href='Perl6_ES10.html'>%Examples{'IO'} = open('Perl6');</a> < <span class='digit'>2005-05-30 00:24:01</span> ></li><li><a href='Perl6_ES11.html'>class Examples11 is Perl6 { ... }</a> < <span class='digit'>2005-05-30 13:31:31</span> ></li><li><a href='Perl6_ES12.html'>$Perl6 = $class.bless(:Example<12>);</a> < <span class='digit'>2005-05-31 11:38:46</span> ></li><li><a href='Perl6_ES13.html'>role Example13 { # Perl6 }</a> < <span class='digit'>2005-05-31 18:22:03</span> ></li><li><a href='Perl6_ES16.html'>my subtype Examples16 of Perl6 where /^kissu$/</a> < <span class='digit'>2005-06-04 23:59:29</span> ></li><li><a href='Perl6_ES17.html'>my enum Example17 <<:Perl(6) Today>></a> < <span class='digit'>2005-06-05 12:14:08</span> ></li><li><a href='Perl6_ES18.html'>my $queen; rule me {Perl6|Examples18}</a> < <span class='digit'>2005-06-06 12:26:32</span> ></li><li><a href='Perl6_ES19.html'>m:nth(19)/Perl6Examples/</a> < <span class='digit'>2005-06-06 22:02:01</span> ></li><li><a href='PBP3.html'>Tips from Perl Best Practices, Part 2</a> < <span class='digit'>2005-09-22 00:29:34</span> ></li><li><a href='Perl6_Rules.html'>用 Perl6::Rules 来写 Formatter</a> < <span class='digit'>2005-09-27 10:02:45</span> ></li><li><a href='mod_perl_learning.html'>a schedule of mod_perl learning</a> < <span class='digit'>2005-11-12 21:53:55</span> ></li><li><a href='mod_perl_configuring.html'>mod_perl 配置的一些指令</a> < <span class='digit'>2005-11-13 11:38:05</span> ></li><li><a href='modperl_helloworld.html'>modperl Apache2::HelloWorld</a> < <span class='digit'>2005-11-16 23:24:07</span> ></li><li><a href='pod2cn.html'>Perl 核心模块中文化</a> < <span class='digit'>2005-11-20 21:43:52</span> ></li><li><a href='modperl_http_cycle.html'>modperl 服务器的运行阶段和句柄</a> < <span class='digit'>2005-11-22 15:33:08</span> ></li><li><a href='modperl_PerlTransHandler.html'>modperl 的 PerlTransHandler 应用</a> < <span class='digit'>2005-11-23 22:24:02</span> ></li><li><a href='modperl_PerlAuthenHandler.html'>modperl 的用户验证</a> < <span class='digit'>2005-11-26 00:08:37</span> ></li><li><a href='modperl_Filter_part1.html'>modperl Filter Part1</a> < <span class='digit'>2005-12-18 14:47:29</span> ></li><li><a href='perldoc_ie.html'>用 IE 来浏览 perldoc</a> < <span class='digit'>2005-12-28 13:53:02</span> ></li></ul>
Created on <span class="digit">2004-12-29 19:00:02</span>, Last modified on <span class="digit">2005-05-21 00:16:22</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>